package com.eig.course.controller;

import com.eig.common.entity.course.EduSubject;
import com.eig.common.vo.Result;
import com.eig.course.service.CoreService;
import com.eig.course.vo.EduSubjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.annotation.Resource;

/**
 * @author ：StudentLsj（李世界）
 * @date ：Created in 2022/12/06 下午 06:06
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/core/subject")
@Api(tags = "课程分类接口")
@EnableSwagger2
public class CoreController {

    @Resource
    private CoreService coreService;

    @PostMapping("/findsubject/{current}/{pageSize}")
    @ApiOperation(value = "分页查询", notes = "根据current和pageSize查询")
    public Result findsubject(@PathVariable Integer current, @PathVariable Integer pageSize, @RequestBody EduSubject eduSubject) {
        PageRequest pageRequest = PageRequest.of(current - 1, pageSize);
        return coreService.findsubject(pageRequest, eduSubject);
    }

    @PostMapping("/updatesubject")
    @ApiOperation(value = "修改", notes = "实体类接收")
    public Result updatesubject(@RequestBody EduSubjectVo eduSubject) {
        return coreService.updatesubject(eduSubject);
    }

    @PostMapping("/insertsubject")
    @ApiOperation(value = "添加")
    public Result insertsubject(@RequestBody EduSubject eduSubject){
        return coreService.insertsubject(eduSubject);
    }

    @PostMapping("changeStatusId")
    @ApiOperation(value = "状态修改")
    public Result changeStatusId(@RequestBody EduSubject eduSubject){
        return coreService.changeStatusId(eduSubject);
    }
}
